load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test")

go_library(
    name = "tenantrate",
    srcs = [
        "doc.go",
        "factory.go",
        "limiter.go",
        "metrics.go",
        "settings.go",
        "system_limiter.go",
    ],
    importpath = "github.com/cockroachdb/cockroach/pkg/kv/kvserver/tenantrate",
    visibility = ["//visibility:public"],
    deps = [
        "//pkg/multitenant",
        "//pkg/multitenant/tenantcapabilities",
        "//pkg/multitenant/tenantcostmodel",
        "//pkg/roachpb",
        "//pkg/settings",
        "//pkg/util/log",
        "//pkg/util/metric",
        "//pkg/util/metric/aggmetric",
        "//pkg/util/quotapool",
        "//pkg/util/syncutil",
        "//pkg/util/timeutil",
        "@com_github_cockroachdb_errors//:errors",
        "@com_github_cockroachdb_tokenbucket//:tokenbucket",
    ],
)

go_test(
    name = "tenantrate_test",
    size = "small",
    srcs = ["limiter_test.go"],
    data = glob(["testdata/**"]),
    deps = [
        ":tenantrate",
        "//pkg/kv/kvpb",
        "//pkg/multitenant/tenantcapabilities",
        "//pkg/multitenant/tenantcapabilities/tenantcapabilitiespb",
        "//pkg/multitenant/tenantcostmodel",
        "//pkg/roachpb",
        "//pkg/settings/cluster",
        "//pkg/testutils",
        "//pkg/testutils/datapathutils",
        "//pkg/testutils/metrictestutils",
        "//pkg/util/leaktest",
        "//pkg/util/metric",
        "//pkg/util/stop",
        "//pkg/util/timeutil",
        "@com_github_cockroachdb_datadriven//:datadriven",
        "@com_github_cockroachdb_errors//:errors",
        "@com_github_dustin_go_humanize//:go-humanize",
        "@com_github_stretchr_testify//assert",
        "@com_github_stretchr_testify//require",
        "@in_gopkg_yaml_v2//:yaml_v2",
    ],
)
